package com.sky.mapper;

import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    /*条件查询购物车中的商品*/
    List<ShoppingCart> SelectCart(ShoppingCart shoppingCart);

    @Insert("insert into shopping_cart(user_id,name,image,dish_id,setmeal_id,dish_flavor,number,amount,create_time) " +
            "values (#{userId},#{name},#{image},#{dishId},#{setmealId},#{dishFlavor},#{number},#{amount},#{createTime})")
    void addCart(ShoppingCart shoppingCart);

    /*根据id设置商品数量*/
    @Update("update shopping_cart set number=#{number} where id=#{id}")
    void setGoodsNumberById(ShoppingCart shoppingCart);

    /*查询购物车*/  /*条件查询 购物车*/
    @Select("select * from shopping_cart")
    List<ShoppingCart> list();

     /*根据用户id清空购物车*/
    @Delete("delete from shopping_cart where user_id=#{userId}")
    void clean(Long userId);

    /*条件删除商品*/
    void deleteCartGoods(ShoppingCart cart);
}
